The three procedures TTTTkkkk____CCCCrrrreeeeaaaatttteeeeMMMMaaaaiiiinnnnWWWWiiiinnnnddddoooowwww, TTTTkkkk____CCCCrrrreeeeaaaatttteeeeWWWWiiiinnnnddddoooowwww,
Either internal or top-level windows may be created by
calling TTTTkkkk____CCCCrrrreeeeaaaatttteeeeWWWWiiiinnnnddddoooowwww. If the _t_o_p_L_e_v_S_c_r_e_e_n argument is
NULL, then the new window will be an internal window. If
_t_o_p_L_e_v_S_c_r_e_e_n is non-NULL, then the new window will be a
top-level window: _t_o_p_L_e_v_S_c_r_e_e_n indicates the name of a
screen and the new window will be created as a child of the
root window of _t_o_p_L_e_v_S_c_r_e_e_n. In either case Tk will
consider the new window to be the logical child of _p_a_r_e_n_t:
the new window's path name will reflect this fact, options
may be specified for the new window under this assumption,
and so on. The only difference is that new X window for a
top-level window will not be a child of _p_a_r_e_n_t's X window.
For example, a pull-down menu's _p_a_r_e_n_t would be the button-
like window used to invoke it, which would in turn be a
child of the menu bar window. A dialog box might have the
application's main window as its parent. This approach
means that all the windows of an application fall into a
hierarchical arrangement with a single logical root: the
application's main window.
TTTTkkkk____CCCCrrrreeeeaaaatttteeeeWWWWiiiinnnnddddoooowwwwFFFFrrrroooommmmPPPPaaaatttthhhh offers an alternate way of
specifying new windows. In TTTTkkkk____CCCCrrrreeeeaaaatttteeeeWWWWiiiinnnnddddoooowwwwFFFFrrrroooommmmPPPPaaaatttthhhh the new
window is specified with a token for any window in the
target application (_t_k_w_i_n), plus a path name for the new
window. It produces the same effect as TTTTkkkk____CCCCrrrreeeeaaaatttteeeeWWWWiiiinnnnddddoooowwww and
allows both top-level and internal windows to be created,
depending on the value of _t_o_p_L_e_v_S_c_r_e_e_n. In calls to
TTTTkkkk____CCCCrrrreeeeaaaatttteeeeWWWWiiiinnnnddddoooowwwwFFFFrrrroooommmmPPPPaaaatttthhhh, as in calls to TTTTkkkk____CCCCrrrreeeeaaaatttteeeeWWWWiiiinnnnddddoooowwww, the
parent of the new window must exist at the time of the call,
but the new window must not already exist.
In truth, the window-creation procedures don't actually
issue the command to X to create a window. Instead, they
create a local data structure associated with the window and
defer the creation of the X window. The window will
actually be created by the first call to TTTTkkkk____MMMMaaaappppWWWWiiiinnnnddddoooowwww.
Deferred window creation allows various aspects of the
window (such as its size, background color, etc.) to be
modified after its creation without incurring any overhead
in the X server. When the window is finally mapped all of
the window attributes can be set while creating the window.
The value returned by a window-creation procedure is not the
X token for the window (it can't be, since X hasn't been
asked to create the window yet). Instead, it is a token for
Tk's local data structure for the window. Most of the Tk
library procedures take Tk_Window tokens, rather than X
identifiers. The actual X window identifier can be
retrieved from the local data structure using the
TTTTkkkk____WWWWiiiinnnnddddoooowwwwIIIIdddd macro; see the manual entry for TTTTkkkk____WWWWiiiinnnnddddoooowwwwIIIIdddd for
TTTTkkkk____DDDDeeeessssttttrrrrooooyyyyWWWWiiiinnnnddddoooowwww deletes a window and all the data strutures
associated with it, including any event handlers created
with TTTTkkkk____CCCCrrrreeeeaaaatttteeeeEEEEvvvveeeennnnttttHHHHaaaannnnddddlllleeeerrrr. In addition, TTTTkkkk____DDDDeeeessssttttrrrrooooyyyyWWWWiiiinnnnddddoooowwww
will delete any children of _t_k_w_i_n recursively (where
children are defined in the Tk sense, consisting of all
windows that were created with the given window as _p_a_r_e_n_t).
If _t_k_w_i_n was created by TTTTkkkk____CCCCrrrreeeeaaaatttteeeeIIIInnnntttteeeerrrrnnnnaaaallllWWWWiiiinnnnddddoooowwww then event
handlers interested in destroy events are invoked
immediately. If _t_k_w_i_n is a top-level or main window, then
the event handlers will be invoked later, after X has seen
the request and returned an event for it.
If a window has been created but hasn't been mapped, so no X
window exists, it is possible to force the creation of the X
window by calling TTTTkkkk____MMMMaaaakkkkeeeeWWWWiiiinnnnddddoooowwwwEEEExxxxiiiisssstttt. This procedure issues
the X commands to instantiate the window given by _t_k_w_i_n.